package com.easipass.framework.eirframeworkjdbc;

import com.easipass.framework.eirframeworkjdbc.model.App;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
@Transactional
public interface AppRepository extends JpaRepository<App, Long> {

    List<App> findAllByName(String name);

    List<App> findAllByType(String type);

    List<App> findAllByNameAndType(String name, String type);

    App findByName(String name);

    App findByNameAndType(String name, String type);

    @Modifying
    @Query("update App as app set app.code=?1,app.describeInfo=?2,app.label=?3 where app.id=?4")
    int updateAppById(String code, String describeInfo, String label, Long id);
}
